package cn.wizzer.app.crown.modules.services.impl.pl.ft;

import cn.wizzer.app.crown.commons.websocket.action.hg.ComplexPlayWayAction;
import cn.wizzer.app.crown.commons.websocket.action.hg.SimplexPlayWayAction;
import cn.wizzer.app.crown.modules.models.CrownConfig;
import cn.wizzer.app.crown.modules.models.CrownMatch;
import cn.wizzer.app.crown.modules.models.caches.CrownMatchSimplex;
import cn.wizzer.app.crown.modules.models.constant.CrownConstant;
import cn.wizzer.app.crown.modules.models.constant.CrownPattern;
import cn.wizzer.app.crown.modules.models.constant.CrownRedisConstant;
import cn.wizzer.app.crown.modules.models.enums.PlayWayEnum;
import cn.wizzer.app.crown.modules.models.vo.AllBets;
import cn.wizzer.app.crown.modules.models.vo.Game;
import cn.wizzer.app.crown.modules.services.CrownConfigService;
import cn.wizzer.app.crown.modules.services.CrownMatchService;
import cn.wizzer.app.crown.modules.services.pl.ft.AllBetsResolverService;
import cn.wizzer.framework.base.exceptions.BizException;
import cn.wizzer.framework.util.JaxbUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSONObject;
import org.nutz.integration.jedis.RedisService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Strings;
import org.nutz.log.Log;
import org.nutz.log.Logs;

import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.util.List;
import java.util.regex.Matcher;

/**
 * 足球今日早盘所有玩法爬取
 */
@IocBean
@Service(interfaceClass = AllBetsResolverService.class)
public class AllBetsResolverServiceImpl implements AllBetsResolverService {

    @Inject
    private RedisService redisService;

    @Inject
    private CrownMatchService matchService;

    @Inject
    @Reference(retries = 0, timeout = 500000)
    private CrownConfigService configService;

    private static final Log log = Logs.get();


    @Override
    public CrownMatch crawler(PlayWayEnum playWay, CrownMatch match, CrownConfig crownConfig) {
        long start = System.currentTimeMillis();
        log.info("发送请求开始" + start + "matchId:" + match.getId());

        // 发送请求，如果失败重试三次
        String body = this.sendRequest(playWay, match, crownConfig);

        log.info("发送请求结束" + (System.currentTimeMillis() - start));
        log.info("AllBets body" + body);
        start = System.currentTimeMillis();
        log.info("解析数据开始" + start);
        // 解析xml
        AllBets allBets = this.parseXML(body);
        // 根据xml转的java bean处理数据，缓存、推送
        this.cacheData(playWay, match, allBets);
        log.info("解析数据结束" + (System.currentTimeMillis() - start));
        log.info("推送所有玩法：allBetsService:" + playWay + "——matchId:" + match.getId() + "——stage:" + match.getStage());
        CrownMatch result;
        if (PlayWayEnum.R.equals(playWay)) {
            result = matchService.composeMatch(CrownRedisConstant.SIMPLEX, match);
            SimplexPlayWayAction.instance().push(match.getId(), result);
        } else {
            result = matchService.composeMatch(CrownRedisConstant.P3, match);
            ComplexPlayWayAction.instance().push(match.getId(), result);
        }
        return result;
    }


    /**
     * 请求皇冠，获取xml
     *
     * @param match
     * @param crownConfig
     * @return
     */
    private String sendRequest(PlayWayEnum playWay, CrownMatch match, CrownConfig crownConfig) {
        String gType;
        String showType;
        // 单式
        if (PlayWayEnum.R.equals(playWay)) {
            gType = "FT";
            switch (match.getStage()) {
                case CrownConstant.FUTURE:
                    showType = "FU";
                    break;
                case CrownConstant.BROWSE:
                    showType = "FT";
                    break;
                default:
                    log.error("赛事stage错误：" + match);
                    throw new BizException("赛事stage错误：" + match);
            }
        } else {
            // 综合
            gType = "FTP";
            showType = "FT";
        }
        // 请求url
        String tailUrl = "/app/member/get_game_allbets.php?uid=" + crownConfig.getUid() + "&langx=" + CrownConstant.LANGX
                + "&gtype=" + gType + "&showtype=" + showType
                + "&gid=" + match.getMid()
                + "&ltype=3&date=1";
        log.info("sendRequest url：" + tailUrl);
        String body = configService.getCrownData(tailUrl, crownConfig, CrownConstant.RE_TRY_TIMES);
        log.info("sendRequest response body：" + body);
        // 检测账号被登出
        if (configService.checkLogout(body, crownConfig)) {
            // 重试登录(包括重试三次、自动请求新地址)
//            configService.loginHg(crownConfig);
//            // 如果登录成功 重新请求数据
//            if (!crownConfig.isLogout()) {
//                return this.sendRequest(playWay, match, crownConfig);
//            }
            return "";
        }
        // body是空，监测到皇冠维护都return
        if (Strings.isBlank(body)) {
            log.error("爬取单式所有玩法失败，body为空");
            return "";
        } else if (configService.checkMaintain(body, crownConfig)) {
            return "";
        }
        return body;
    }


    /**
     * 解析XML转换成java bean
     *
     * @param body
     * @return
     */
    private AllBets parseXML(String body) {
        Matcher matcher = CrownPattern.MASTER_GAME_LABEL.matcher(body);
        StringBuilder sb = new StringBuilder(body);
        if (matcher.find()) {
            // 情况1的<game>标签钱插入<gameList>标签
            sb.insert(sb.indexOf(matcher.group()), "<gameList>");
            // <showtype>标签后插入<gameList>标签
            sb.insert(sb.indexOf("<showtype>"), "</gameList>");
        } else {
            throw new BizException("‘所有玩法’数据不存在，body：" + body);
        }
        // 将xml字符串转换为java对象
        JaxbUtil jaxbUtil = new JaxbUtil(AllBets.class, JaxbUtil.CollectionWrapper.class);
        return jaxbUtil.fromXml(sb.toString());
    }


    /**
     * 处理数据，缓存至redis并推送
     *
     * @param allBets
     */
    private void cacheData(PlayWayEnum playWay, CrownMatch match, AllBets allBets) {
        log.info("all bets:" + allBets);
        CrownMatchSimplex simplex = new CrownMatchSimplex();
        simplex.setCrownMatchId(match.getId());
        simplex.setMatchType(match.getType());
        simplex.setPlayWay(playWay);

        List<Game> gameList = allBets.getGameList();
        for (int i = 0; i < gameList.size(); i++) {
            Game game = gameList.get(i);
            // game的index就是‘情况’
            game.setIndex(i + 1);


            // 8：半场波胆
            this.halfPd(game, simplex);
            // 9：全场波胆
            this.fullPd(game, simplex);
            // 10：半场总入球
            this.halfT(game, simplex);
            // 11：全场总入球
            this.fullT(game, simplex);
            // 12：半场/全场
            this.halfOrFullWin(game, simplex);

            // 13：(15分钟盘口)开场 - 14:59 分钟 - 让球
            this.stageLetBall(game, simplex, "A-13");
            // 14：(15分钟盘口)开场 - 14:59 分钟 - 大 / 小
            this.stageBigOrSmall(game, simplex, "A-14");
            // 15：(15分钟盘口)开场 - 14:59 分钟 - 独赢
            this.stageWin(game, simplex, "A-15");

            // 16：(15分钟盘口)15:00 - 29:59 分钟 - 让球
            this.stageLetBall(game, simplex, "B-16");
            // 17：(15分钟盘口)15:00 - 29:59 分钟 - 大 / 小
            this.stageBigOrSmall(game, simplex, "B-17");
            // 18：(15分钟盘口)15:00 - 29:59 分钟 - 独赢
            this.stageWin(game, simplex, "B-18");

            // 19：(15分钟盘口)30:00 分钟 - 半场 - 让球
            this.stageLetBall(game, simplex, "C-19");
            // 20：(15分钟盘口)30:00 分钟 - 半场 - 大 / 小
            this.stageBigOrSmall(game, simplex, "C-20");
            // 21：(15分钟盘口)30:00 分钟 - 半场 - 独赢
            this.stageWin(game, simplex, "C-21");

            // 22：(15分钟盘口)下半场开始 - 59:59 分钟 - 让球
            this.stageLetBall(game, simplex, "D-22");
            // 23：(15分钟盘口)下半场开始 - 59:59 分钟 - 大 / 小
            this.stageBigOrSmall(game, simplex, "D-23");
            // 24：(15分钟盘口)下半场开始 - 59:59 分钟 - 独赢
            this.stageWin(game, simplex, "D-24");

            // 25：(15分钟盘口)60:00 - 74:59 分钟 - 让球
            this.stageLetBall(game, simplex, "E-25");
            // 26：(15分钟盘口)60:00 - 74:59 分钟 - 大 / 小
            this.stageBigOrSmall(game, simplex, "E-26");
            // 27：(15分钟盘口)60:00 - 74:59 分钟 - 独赢
            this.stageWin(game, simplex, "E-27");

            // 28：(15分钟盘口)75:00 分钟 - 全场 - 让球
            this.stageLetBall(game, simplex, "F-28");
            // 29：(15分钟盘口)75:00 分钟 - 全场 - 大 / 小
            this.stageBigOrSmall(game, simplex, "F-29");
            // 30：(15分钟盘口)75:00 分钟 - 全场 - 独赢
            this.stageWin(game, simplex, "F-30");

            // 31：双方球队进球
            this.fullAllTeamGoals(game, simplex);
            // 32：上半场双方球队进球
            this.halfAllTeamGoals(game, simplex);

            // 33: 下半场球队进球（今日早盘中不存在）

            // 34：全场球队进球数大
            // 35：全场球队进球数小
            this.fullTeamGoalsBigOrSmall(game, simplex);
            // 36：半场球队进球数大
            // 37：半场球队进球数小
            this.halfTeamGoalsBigOrSmall(game, simplex);

            // 38：半场单双
            this.halfSingleOrDouble(game, simplex);
            // 39：净胜球数
            this.goalDifference(game, simplex);

            // 40：双重机会
            this.doubleChance(game, simplex);
            // 41：零失球
            this.zeroLose(game, simplex);
            // 42：零失球获胜
            this.zeroLoseAndWin(game, simplex);

            // 43：独赢 & 进球 大 / 小
            this.fullCourtWinAndBigSmall(match, game, simplex);
            // 44：独赢 & 双方球队进球
            this.fullCourtWinAndAllTeamGoals(match, game, simplex);

            // 45：最多进球的半场
            this.halfMostGoals(game, simplex);
            // 46：最多进球的半场 - 独赢
            this.halfCourtMostGoalsWin(game, simplex);
            // 47：双半场进球
            this.doubleHalfCourtGoals(game, simplex);

            // 48：双重机会 & 进球 大 / 小
            this.doubleChanceAndBigSmall(match, game, simplex);
            // 49：双重机会 & 双方球队进球
            this.doubleChanceAndAllTeamGoals(game, simplex);
            // 50：进球 大 / 小 & 进球 单 / 双
            this.goalsBigSmallAndSingleDouble(match, game, simplex);
            // 51：赢得任一半场
            this.winAnyHalfCourt(game, simplex);
            // 52：赢得所有半场
            this.winAllHalfCourt(game, simplex);
        }
    }


    /**
     * 用的是同一个simplex对象，缓存前要把一些属性置空
     *
     * @param simplex
     */
    private void clearAttr(CrownMatchSimplex simplex) {
        simplex.setCoeNum(null);
        simplex.setCoeWord(null);
    }

    /**
     * redis缓存数据
     *
     * @param simplex
     */
    private void compose(CrownMatchSimplex simplex) {
        // 设置redisKey
        String redisKey;
        if (PlayWayEnum.R.equals(simplex.getPlayWay())) {
            redisKey = CrownRedisConstant.SIMPLEX + simplex.getCrownMatchId();
        } else {
            redisKey = CrownRedisConstant.P3 + simplex.getCrownMatchId();
        }

        // 存入redis并设置过期时间
        redisService.setex(redisKey + ":" + simplex.getNo1() + ":" + simplex.getNo2() + ":" + simplex.getNo3(),
                CrownRedisConstant.TIME_OUT_180_S,
                JSONObject.toJSONString(simplex));
    }

    /**
     * 半场波胆
     *
     * @param game
     * @param simplex
     */
    private void halfPd(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_HPD())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(8);
        // 1-0
        simplex.setCoeWord("1-0");
        simplex.setNo2(1);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH1C0());
        this.compose(simplex);

        // 2-0
        simplex.setCoeWord("2-0");
        simplex.setNo2(2);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH2C0());
        this.compose(simplex);

        // 2-1
        simplex.setCoeWord("2-1");
        simplex.setNo2(3);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH2C1());
        this.compose(simplex);

        // 3-0
        simplex.setCoeWord("3-0");
        simplex.setNo2(4);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH3C0());
        this.compose(simplex);

        // 3-1
        simplex.setCoeWord("3-1");
        simplex.setNo2(5);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH3C1());
        this.compose(simplex);


        // 3-2
        simplex.setCoeWord("3-2");
        simplex.setNo2(6);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HH3C2());
        this.compose(simplex);


        // 0-0
        simplex.setCoeWord("0-0");
        simplex.setNo2(1);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_HH0C0());
        this.compose(simplex);


        // 1-1
        simplex.setCoeWord("1-1");
        simplex.setNo2(2);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_HH1C1());
        this.compose(simplex);


        // 2-2
        simplex.setCoeWord("2-2");
        simplex.setNo2(3);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_HH2C2());
        this.compose(simplex);


        // 3-3
        simplex.setCoeWord("3-3");
        simplex.setNo2(4);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_HH3C3());
        this.compose(simplex);


        // 其他
        simplex.setNo2(0);
        simplex.setNo3(0);
        simplex.setCoeWord("其他");
        simplex.setOdds(game.getIor_HOVH());
        this.compose(simplex);


        // 0-1
        simplex.setNo2(1);
        simplex.setNo3(2);
        simplex.setCoeWord("0-1");
        simplex.setOdds(game.getIor_HH0C1());
        this.compose(simplex);


        // 0-2
        simplex.setNo2(2);
        simplex.setNo3(2);
        simplex.setCoeWord("0-2");
        simplex.setOdds(game.getIor_HH0C2());
        this.compose(simplex);


        // 1-2
        simplex.setNo2(3);
        simplex.setNo3(2);
        simplex.setCoeWord("1-2");
        simplex.setOdds(game.getIor_HH1C2());
        this.compose(simplex);


        // 0-3
        simplex.setNo2(4);
        simplex.setNo3(2);
        simplex.setCoeWord("0-3");
        simplex.setOdds(game.getIor_HH0C3());
        this.compose(simplex);


        // 1-3
        simplex.setNo2(5);
        simplex.setNo3(2);
        simplex.setCoeWord("1-3");
        simplex.setOdds(game.getIor_HH1C3());
        this.compose(simplex);


        // 2-3
        simplex.setNo2(6);
        simplex.setNo3(2);
        simplex.setCoeWord("2-3");
        simplex.setOdds(game.getIor_HH2C3());
        this.compose(simplex);
    }


    /**
     * 全场波胆
     *
     * @param game
     * @param simplex
     */
    private void fullPd(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_PD())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(9);

        // 1-0
        simplex.setCoeWord("1-0");
        simplex.setNo2(1);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H1C0());
        this.compose(simplex);

        // 2-0
        simplex.setCoeWord("2-0");
        simplex.setNo2(2);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H2C0());
        this.compose(simplex);

        // 2-1
        simplex.setCoeWord("2-1");
        simplex.setNo2(3);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H2C1());
        this.compose(simplex);

        // 3-0
        simplex.setCoeWord("3-0");
        simplex.setNo2(4);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H3C0());
        this.compose(simplex);

        // 3-1
        simplex.setCoeWord("3-1");
        simplex.setNo2(5);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H3C1());
        this.compose(simplex);

        // 3-2
        simplex.setCoeWord("3-2");
        simplex.setNo2(6);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H3C2());
        this.compose(simplex);

        // 4-0
        simplex.setCoeWord("4-0");
        simplex.setNo2(7);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H4C0());
        this.compose(simplex);

        // 4-1
        simplex.setCoeWord("4-1");
        simplex.setNo2(8);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H4C1());
        this.compose(simplex);


        // 4-2
        simplex.setCoeWord("4-2");
        simplex.setNo2(9);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H4C2());
        this.compose(simplex);


        // 4-3
        simplex.setCoeWord("4-3");
        simplex.setNo2(10);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_H4C3());
        this.compose(simplex);

        // 其他
        simplex.setCoeWord("其他");
        simplex.setNo2(0);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_OVH());
        this.compose(simplex);

        // 0-0
        simplex.setCoeWord("0-0");
        simplex.setNo2(1);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_H0C0());
        this.compose(simplex);

        // 1-1
        simplex.setCoeWord("1-1");
        simplex.setNo2(2);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_H1C1());
        this.compose(simplex);

        // 2-2
        simplex.setCoeWord("2-2");
        simplex.setNo2(3);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_H2C2());
        this.compose(simplex);

        // 3-3
        simplex.setCoeWord("3-3");
        simplex.setNo2(4);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_H3C3());
        this.compose(simplex);

        // 4-4
        simplex.setCoeWord("4-4");
        simplex.setNo2(5);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_H4C4());
        this.compose(simplex);

        // 0-1
        simplex.setCoeWord("0-1");
        simplex.setNo2(1);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H0C1());
        this.compose(simplex);

        // 0-2
        simplex.setCoeWord("0-2");
        simplex.setNo2(2);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H0C2());
        this.compose(simplex);

        // 1-2
        simplex.setCoeWord("1-2");
        simplex.setNo2(3);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H1C2());
        this.compose(simplex);

        // 0-3
        simplex.setCoeWord("0-3");
        simplex.setNo2(4);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H0C3());
        this.compose(simplex);

        // 1-3
        simplex.setCoeWord("1-3");
        simplex.setNo2(5);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H1C3());
        this.compose(simplex);

        // 2-3
        simplex.setCoeWord("2-3");
        simplex.setNo2(6);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H2C3());
        this.compose(simplex);

        // 0-4
        simplex.setCoeWord("0-4");
        simplex.setNo2(7);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H0C4());
        this.compose(simplex);

        // 1-4
        simplex.setCoeWord("1-4");
        simplex.setNo2(8);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H1C4());
        this.compose(simplex);


        // 2-4
        simplex.setCoeWord("2-4");
        simplex.setNo2(9);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H2C4());
        this.compose(simplex);


        // 3-4
        simplex.setCoeWord("3-4");
        simplex.setNo2(10);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_H3C4());
        this.compose(simplex);
    }


    /**
     * 半场总入球
     *
     * @param game
     * @param simplex
     */
    private void halfT(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_HT())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(10);

        // 0
        simplex.setCoeWord("0");
        simplex.setNo2(1);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_HT0());
        this.compose(simplex);

        // 1
        simplex.setCoeWord("1");
        simplex.setNo2(2);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_HT1());
        this.compose(simplex);

        // 2
        simplex.setCoeWord("2");
        simplex.setNo2(3);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_HT2());
        this.compose(simplex);


        // 3+
        simplex.setCoeWord("3+");
        simplex.setNo2(4);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_HTOV());
        this.compose(simplex);
    }


    /**
     * 全场总入球
     *
     * @param game
     * @param simplex
     */
    private void fullT(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_T())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(11);

        // 0~1
        simplex.setCoeWord("0~1");
        simplex.setNo2(1);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_T01());
        this.compose(simplex);

        // 2~3
        simplex.setCoeWord("2~3");
        simplex.setNo2(2);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_T23());
        this.compose(simplex);

        // 4~6
        simplex.setCoeWord("4~6");
        simplex.setNo2(3);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_T46());
        this.compose(simplex);


        // 7+
        simplex.setCoeWord("7+");
        simplex.setNo2(4);
        simplex.setNo3(0);
        simplex.setOdds(game.getIor_OVER());
        this.compose(simplex);
    }


    /**
     * 半/全场
     *
     * @param game
     * @param simplex
     */
    private void halfOrFullWin(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_F())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(12);

        // 胜 1 负2 平3。no3记录半场胜负平，no2记录全场胜负平。
        // 主/主
        simplex.setCoeWord("主/主");
        simplex.setNo2(1);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_FHH());
        this.compose(simplex);

        // 主/和
        simplex.setCoeWord("主/和");
        simplex.setNo2(3);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_FHN());
        this.compose(simplex);

        // 主/客
        simplex.setCoeWord("主/客");
        simplex.setNo2(2);
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_FHC());
        this.compose(simplex);

        // 和/主
        simplex.setCoeWord("和/主");
        simplex.setNo2(1);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_FNH());
        this.compose(simplex);

        // 和/和
        simplex.setCoeWord("和/和");
        simplex.setNo2(3);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_FNN());
        this.compose(simplex);

        // 和/客
        simplex.setCoeWord("和/客");
        simplex.setNo2(2);
        simplex.setNo3(3);
        simplex.setOdds(game.getIor_FNC());
        this.compose(simplex);

        // 客/主
        simplex.setCoeWord("客/主");
        simplex.setNo2(1);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_FCH());
        this.compose(simplex);

        // 客/和
        simplex.setCoeWord("客/和");
        simplex.setNo2(2);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_FCN());
        this.compose(simplex);

        // 客/客
        simplex.setCoeWord("客/客");
        simplex.setNo2(2);
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_FCC());
        this.compose(simplex);
    }


    /**
     * 15分钟盘口 - 让球
     *
     * @param game
     * @param simplex
     */
    private void stageLetBall(Game game, CrownMatchSimplex simplex, String stage) {
        try {
            int no1 = Integer.parseInt(stage.split("-")[1]);
            stage = stage.split("-")[0];
            // 判断玩法是否开启。拼接getSW_AR()方法
            String result = (String) Game.class.getMethod("getSw_" + stage + "R").invoke(game);
            if ("N".equals(result)) {
                return;
            }

            this.clearAttr(simplex);
            // 主队是否是强队
            boolean hTeamIsStrong = "H".equals(game.getStrong());
            // 让球系数 拼接getRatio_ar()方法
            String coeNum = (String) Game.class.getMethod("getRatio_" + stage.toLowerCase() + "r").invoke(game);

            // 从map中取到no1
            simplex.setNo1(no1);

            // 主队
            simplex.setNo2(game.getIndex());
            simplex.setNo3(1);
            // 主队赔率 拼接getIor_ARH()方法
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "RH").invoke(game));
            simplex.setCoeNum((hTeamIsStrong ? "" : "-") + coeNum);
            this.compose(simplex);

            // 客队
            simplex.setNo2(game.getIndex());
            simplex.setNo3(2);
            // 客队赔率 拼接getIor_ARC()方法
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "RC").invoke(game));
            simplex.setCoeNum((hTeamIsStrong ? "-" : "") + coeNum);
            this.compose(simplex);

        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 15分钟盘口 - 大小
     *
     * @param game
     * @param simplex
     */
    private void stageBigOrSmall(Game game, CrownMatchSimplex simplex, String stage) {
        try {
            int no1 = Integer.parseInt(stage.split("-")[1]);
            stage = stage.split("-")[0];
            // 拼接方法名 getSw_AOU()并执行
            String result = (String) Game.class.getMethod("getSw_" + stage + "OU").invoke(game);
            // 判断玩法是否开启
            if ("N".equals(result)) {
                return;
            }
            this.clearAttr(simplex);
            // 从map中获取no1
            simplex.setNo1(no1);

            // ‘大’
            simplex.setNo2(game.getIndex());
            simplex.setNo3(1);
            // 拼接getIor_AOUO()方法名 并执行获取 ‘大’赔率
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "OUO").invoke(game));
            // 拼接getRatio_aouo()方法名 并执行获取 ‘大’系数
            simplex.setCoeNum((String) Game.class.getMethod("getRatio_" + stage.toLowerCase() + "ouo").invoke(game));
            simplex.setCoeWord("大");
            this.compose(simplex);

            // ‘小’
            simplex.setNo2(game.getIndex());
            simplex.setNo3(2);
            // 拼接getIor_AOUU()方法名并执行 获取 ‘小’赔率
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "OUU").invoke(game));
            // 拼接getRatio_aouu()方法名并执行 获取 ‘小’系数
            simplex.setCoeNum((String) Game.class.getMethod("getRatio_" + stage.toLowerCase() + "ouu").invoke(game));
            simplex.setCoeWord("小");
            this.compose(simplex);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 15分钟盘口 - 独赢
     *
     * @param game
     * @param simplex
     */
    private void stageWin(Game game, CrownMatchSimplex simplex, String stage) {
        try {
            int no1 = Integer.parseInt(stage.split("-")[1]);
            stage = stage.split("-")[0];
            // 拼接方法名 getSw_AM()并执行
            String result = (String) Game.class.getMethod("getSw_" + stage + "M").invoke(game);
            // 判断玩法是否开启
            if ("N".equals(result)) {
                return;
            }
            this.clearAttr(simplex);
            simplex.setNo1(no1);

            // 主队
            simplex.setNo2(game.getIndex());
            simplex.setNo3(1);
            // 拼接getIor_AMH()方法名并执行 获取主队赔率
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "MH").invoke(game));
            this.compose(simplex);

            // 客队
            simplex.setNo2(game.getIndex());
            simplex.setNo3(2);
            // 拼接game.getIor_AMC()方法名并执行 获取客队赔率
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "MC").invoke(game));
            this.compose(simplex);

            // 和局
            simplex.setNo2(game.getIndex());
            simplex.setNo3(3);
            // 拼接game.getIor_AMN()方法名并执行 获取和局赔率
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_" + stage + "MN").invoke(game));
            this.compose(simplex);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 全场-双方球队进球
     *
     * @param game
     * @param simplex
     */
    private void fullAllTeamGoals(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_TS())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(31);

        // ‘是’
        simplex.setCoeWord("是");
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_TSY());
        this.compose(simplex);

        // ‘不是’
        simplex.setCoeWord("不是");
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_TSN());
        this.compose(simplex);
    }

    /**
     * 半场-双方球队进球
     *
     * @param game
     * @param simplex
     */
    private void halfAllTeamGoals(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_HTS())) {
            return;
        }
        this.clearAttr(simplex);
        simplex.setNo1(32);

        // ‘是’
        simplex.setCoeWord("是");
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HTSY());
        this.compose(simplex);

        // ‘不是’
        simplex.setCoeWord("不是");
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_HTSN());
        this.compose(simplex);
    }

    /**
     * 球队进球数大小-全场
     *
     * @param game
     * @param simplex
     */
    private void fullTeamGoalsBigOrSmall(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_OUH()) || "N".equals(game.getSw_OUC())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(34);
        simplex.setCoeWord("大");

        // 主队-大
        simplex.setCoeNum(game.getRatio_ouho());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_OUHO());
        this.compose(simplex);

        // 客队-大
        simplex.setCoeNum(game.getRatio_ouco());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_OUCO());
        this.compose(simplex);


        simplex.setNo1(35);
        simplex.setCoeWord("小");

        // 主队-小
        simplex.setCoeNum(game.getRatio_ouhu());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_OUHU());
        this.compose(simplex);

        // 客队-小
        simplex.setCoeNum(game.getRatio_oucu());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_OUCU());
        this.compose(simplex);
    }


    /**
     * 球队进球数大小-半场
     *
     * @param game
     * @param simplex
     */
    private void halfTeamGoalsBigOrSmall(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_HOUH()) || "N".equals(game.getSw_HOUC())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(36);
        simplex.setCoeWord("大");

        // 主队-大
        simplex.setCoeNum(game.getRatio_houho());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HOUHO());
        this.compose(simplex);

        // 客队-大
        simplex.setCoeNum(game.getRatio_houco());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_HOUCO());
        this.compose(simplex);


        simplex.setNo1(37);
        simplex.setCoeWord("小");

        // 主队-小
        simplex.setCoeNum(game.getRatio_houhu());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_HOUHU());
        this.compose(simplex);

        // 客队-小
        simplex.setCoeNum(game.getRatio_houcu());
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_HOUCU());
        this.compose(simplex);
    }


    /**
     * 单双-半场
     *
     * @param game
     * @param simplex
     */
    private void halfSingleOrDouble(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_HEO())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(38);

        // 单
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord("单");
        simplex.setOdds(game.getIor_HEOO());
        this.compose(simplex);

        // 双
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord("双");
        simplex.setOdds(game.getIor_HEOE());
        this.compose(simplex);
    }


    /**
     * 净胜球数
     *
     * @param game
     * @param simplex
     */
    private void goalDifference(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_WM())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(39);

        // 主队净胜一球
        simplex.setNo2(1);
        simplex.setNo3(1);
        simplex.setCoeWord("净胜1球");
        simplex.setOdds(game.getIor_WMH1());
        this.compose(simplex);

        // 主队净胜二球
        simplex.setNo2(2);
        simplex.setNo3(1);
        simplex.setCoeWord("净胜2球");
        simplex.setOdds(game.getIor_WMH2());
        this.compose(simplex);

        // 主队净胜三球
        simplex.setNo2(3);
        simplex.setNo3(1);
        simplex.setCoeWord("净胜3球");
        simplex.setOdds(game.getIor_WMH3());
        this.compose(simplex);

        // 主队净胜四球
        simplex.setNo2(4);
        simplex.setNo3(1);
        simplex.setCoeWord("净胜4球或更多");
        simplex.setOdds(game.getIor_WMHOV());
        this.compose(simplex);

        // 0-0 和局
        simplex.setNo2(1);
        simplex.setNo3(3);
        simplex.setCoeWord("0-0 和局");
        simplex.setOdds(game.getIor_WM0());
        this.compose(simplex);

        // 任何进球和局
        simplex.setNo2(2);
        simplex.setNo3(3);
        simplex.setCoeWord("任何进球和局");
        simplex.setOdds(game.getIor_WMN());
        this.compose(simplex);

        // 客队净胜一球
        simplex.setNo2(1);
        simplex.setNo3(2);
        simplex.setCoeWord("净胜1球");
        simplex.setOdds(game.getIor_WMC1());
        this.compose(simplex);

        // 客队净胜二球
        simplex.setNo2(2);
        simplex.setNo3(2);
        simplex.setCoeWord("净胜2球");
        simplex.setOdds(game.getIor_WMC2());
        this.compose(simplex);

        // 客队净胜三球
        simplex.setNo2(3);
        simplex.setNo3(2);
        simplex.setCoeWord("净胜3球");
        simplex.setOdds(game.getIor_WMC3());
        this.compose(simplex);

        // 客队净胜四球或更多
        simplex.setNo2(4);
        simplex.setNo3(2);
        simplex.setCoeWord("净胜4球或更多");
        simplex.setOdds(game.getIor_WMCOV());
        this.compose(simplex);

    }


    /**
     * 双重机会
     *
     * @param game
     * @param simplex
     */
    private void doubleChance(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_DC())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(40);

        // 主队/和局
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord("主/和");
        simplex.setOdds(game.getIor_DCHN());
        this.compose(simplex);

        // 客队/和局
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord("客/和");
        simplex.setOdds(game.getIor_DCCN());
        this.compose(simplex);

        // 主队/客队
        simplex.setNo2(game.getIndex());
        simplex.setNo3(3);
        simplex.setCoeWord("主/客");
        simplex.setOdds(game.getIor_DCHC());
        this.compose(simplex);
    }


    /**
     * 零失球
     *
     * @param game
     * @param simplex
     */
    private void zeroLose(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_CS())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(41);

        // 主队
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_CSH());
        this.compose(simplex);

        // 客队
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_CSC());
        this.compose(simplex);

    }


    /**
     * 零失球获胜
     *
     * @param game
     * @param simplex
     */
    private void zeroLoseAndWin(Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_WN())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(42);

        // 主队
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_WNH());
        this.compose(simplex);

        // 客队
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_WNC());
        this.compose(simplex);
    }


    /**
     * 独赢 & 进球大/小
     *
     * @param match
     * @param game
     * @param simplex
     */
    private void fullCourtWinAndBigSmall(CrownMatch match, Game game, CrownMatchSimplex simplex) {
        // 情况1
        this.fullCourtWinAndBigSmall(match, game, simplex, "A");
        // 情况2
        this.fullCourtWinAndBigSmall(match, game, simplex, "B");
        // 情况3
        this.fullCourtWinAndBigSmall(match, game, simplex, "C");
        // 情况4
        this.fullCourtWinAndBigSmall(match, game, simplex, "D");
    }

    /**
     * 不同情况 "独赢 & 进球大/小" 方法抽取
     *
     * @param match
     * @param game
     * @param simplex
     * @param stage
     */
    private void fullCourtWinAndBigSmall(CrownMatch match, Game game, CrownMatchSimplex simplex, String stage) {
        try {
            // 拼接方法名getSw_MOUA()并执行
            String result = (String) Game.class.getMethod("getSw_MOU" + stage).invoke(game);
            // 判断玩法是否开启
            if ("N".equals(result)) {
                return;
            }
            this.clearAttr(simplex);

            String coeNum;
            int no2;
            // 固定系数
            switch (stage) {
                case "A":
                    coeNum = "1.5";
                    no2 = 1;
                    break;
                case "B":
                    coeNum = "2.5";
                    no2 = 2;
                    break;
                case "C":
                    coeNum = "3.5";
                    no2 = 3;
                    break;
                case "D":
                    coeNum = "4.5";
                    no2 = 4;
                    break;
                default:
                    throw new BizException("stage参数传错：" + stage);
            }

            simplex.setNo1(43);
            simplex.setNo2(no2);
            simplex.setCoeNum(coeNum);

            // 主队赢 &进球大
            simplex.setNo3(1);
            // simplex.setOdds(game.getIor_MOUAHO());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "HO").invoke(game));
            simplex.setCoeWord(match.getMbTeam() + "&大");
            this.compose(simplex);

            // 主队赢 &进球小
            simplex.setNo3(-1);
            // simplex.setOdds(game.getIor_MOUAHU());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "HU").invoke(game));
            simplex.setCoeWord(match.getMbTeam() + "&小");
            this.compose(simplex);

            // 客队赢 &进球大
            simplex.setNo3(2);
            // simplex.setOdds(game.getIor_MOUACO());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "CO").invoke(game));
            simplex.setCoeWord(match.getTgTeam() + "&大");
            this.compose(simplex);

            // 客队赢 &进球小
            simplex.setNo3(-2);
            // simplex.setOdds(game.getIor_MOUACU());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "CU").invoke(game));
            simplex.setCoeWord(match.getTgTeam() + "&小");
            this.compose(simplex);

            // 和局 &进球大
            simplex.setNo3(3);
            // simplex.setOdds(game.getIor_MOUANO());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "NO").invoke(game));
            simplex.setCoeWord("和局&大");
            this.compose(simplex);

            // 和局 &进球小
            simplex.setNo3(-3);
            // simplex.setOdds(game.getIor_MOUANU());
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_MOU" + stage + "NU").invoke(game));
            simplex.setCoeWord("和局&小");
            this.compose(simplex);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 独赢 &双方球队进球
     *
     * @param match
     * @param game
     * @param simplex
     */
    private void fullCourtWinAndAllTeamGoals(CrownMatch match, Game game, CrownMatchSimplex simplex) {
        // 判断玩法是否开启
        if ("N".equals(game.getSw_MTS())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(44);

        // 主队赢 &双方进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord(match.getMbTeam() + "&是");
        simplex.setOdds(game.getIor_MTSHY());
        this.compose(simplex);

        // 主队赢 &双方不进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-1);
        simplex.setCoeWord(match.getMbTeam() + "&不是");
        simplex.setOdds(game.getIor_MTSHN());
        this.compose(simplex);

        // 客队赢 &双方进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord(match.getTgTeam() + "&是");
        simplex.setOdds(game.getIor_MTSCY());
        this.compose(simplex);

        // 客队赢 &双方不进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-2);
        simplex.setCoeWord(match.getTgTeam() + "&不是");
        simplex.setOdds(game.getIor_MTSCN());
        this.compose(simplex);

        // 和局 &双方进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(3);
        simplex.setCoeWord("和局&是");
        simplex.setOdds(game.getIor_MTSNY());
        this.compose(simplex);

        // 和局 &双方不进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-3);
        simplex.setCoeWord("和局&不是");
        simplex.setOdds(game.getIor_MTSNN());
        this.compose(simplex);
    }


    /**
     * 最多进球的半场
     *
     * @param game
     * @param simplex
     */
    private void halfMostGoals(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_HG())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(45);

        // 最多进球的是上半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord("上半场");
        simplex.setOdds(game.getIor_HGH());
        this.compose(simplex);

        // 最多进球的是下半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord("下半场");
        simplex.setOdds(game.getIor_HGC());
        this.compose(simplex);
    }


    /**
     * 最多进球的半场 - 独赢
     *
     * @param game
     * @param simplex
     */
    private void halfCourtMostGoalsWin(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_MG())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(46);

        // 上半场独赢
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord("上半场");
        simplex.setOdds(game.getIor_MGH());
        this.compose(simplex);

        // 下半场独赢
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord("下半场");
        simplex.setOdds(game.getIor_MGC());
        this.compose(simplex);

        // 和局
        simplex.setNo2(game.getIndex());
        simplex.setNo3(3);
        simplex.setCoeWord("和局");
        simplex.setOdds(game.getIor_MGN());
        this.compose(simplex);
    }


    /**
     * 双半场进球
     *
     * @param game
     * @param simplex
     */
    private void doubleHalfCourtGoals(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_SB())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(47);

        // 主队双半场进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_SBH());
        this.compose(simplex);

        // 客队双半场进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_SBC());
        this.compose(simplex);
    }


    /**
     * 双重机会 & 进球 大/小
     *
     * @param match
     * @param game
     * @param simplex
     */
    private void doubleChanceAndBigSmall(CrownMatch match, Game game, CrownMatchSimplex simplex) {
        // 情况1
        this.doubleChanceAndBigSmall(match, game, simplex, "A");
        // 情况2
        this.doubleChanceAndBigSmall(match, game, simplex, "B");
        // 情况3
        this.doubleChanceAndBigSmall(match, game, simplex, "C");
        // 情况4
        this.doubleChanceAndBigSmall(match, game, simplex, "D");
    }

    /**
     * 不同情况 "双重机会 & 进球 大/小" 方法抽取
     *
     * @param game
     * @param simplex
     * @param stage
     */
    private void doubleChanceAndBigSmall(CrownMatch match, Game game, CrownMatchSimplex simplex, String stage) {
        try {
            // 拼接方法名getSw_DUA()并执行
            String result = (String) Game.class.getMethod("getSw_DU" + stage).invoke(game);
            // 判断玩法是否开启
            if ("N".equals(result)) {
                return;
            }
            this.clearAttr(simplex);

            String coeNum;
            int no2;
            // 固定系数
            switch (stage) {
                case "A":
                    coeNum = "1.5";
                    no2 = 1;
                    break;
                case "B":
                    coeNum = "2.5";
                    no2 = 2;
                    break;
                case "C":
                    coeNum = "3.5";
                    no2 = 3;
                    break;
                case "D":
                    coeNum = "4.5";
                    no2 = 4;
                    break;
                default:
                    throw new BizException("stage参数传错：" + stage);
            }

            simplex.setNo1(48);
            simplex.setNo2(no2);
            simplex.setCoeNum(coeNum);

            // 主队赢/和局 &进球大
            simplex.setNo3(1);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "HO").invoke(game));
            simplex.setCoeWord("主/和&大");
            this.compose(simplex);

            // 主队赢/和局 &进球小
            simplex.setNo3(-1);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "HU").invoke(game));
            simplex.setCoeWord("主/和&小");
            this.compose(simplex);

            // 客队赢/和局 &进球大
            simplex.setNo3(2);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "CO").invoke(game));
            simplex.setCoeWord("客/和&大");
            this.compose(simplex);

            // 客队赢/和局 &进球小
            simplex.setNo3(-2);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "CU").invoke(game));
            simplex.setCoeWord("客/和&小");
            this.compose(simplex);

            // 主队赢/客队赢 &进球大
            simplex.setNo3(3);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "SO").invoke(game));
            simplex.setCoeWord("主/客&大");
            this.compose(simplex);

            // 主队赢/客队赢 &进球小
            simplex.setNo3(-3);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_DU" + stage + "SU").invoke(game));
            simplex.setCoeWord("主/客&小");
            this.compose(simplex);

        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 双重机会 & 双方球队进球
     *
     * @param game
     * @param simplex
     */
    private void doubleChanceAndAllTeamGoals(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_DS())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(49);

        // 主队赢/和局 &双方球队有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setCoeWord("主/和&是");
        simplex.setOdds(game.getIor_DSHY());
        this.compose(simplex);

        // 主队/和局 &双方球队没有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-1);
        simplex.setCoeWord("主/和&不是");
        simplex.setOdds(game.getIor_DSHN());
        this.compose(simplex);


        // 客队赢/和局 &双方球队有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setCoeWord("客/和&是");
        simplex.setOdds(game.getIor_DSCY());
        this.compose(simplex);

        // 客队赢/和局 &双方球队没有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-2);
        simplex.setCoeWord("客/和&不是");
        simplex.setOdds(game.getIor_DSCN());
        this.compose(simplex);


        // 主队赢/客队赢 &双方球队有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(3);
        simplex.setCoeWord("主/客&是");
        simplex.setOdds(game.getIor_DSSY());
        this.compose(simplex);

        // 主队赢/客队赢 &双方球队没有进球
        simplex.setNo2(game.getIndex());
        simplex.setNo3(-3);
        simplex.setCoeWord("主/客&不是");
        simplex.setOdds(game.getIor_DSSN());
        this.compose(simplex);
    }


    /**
     * 进球 大/小 & 进球 单/双
     *
     * @param match
     * @param game
     * @param simplex
     */
    private void goalsBigSmallAndSingleDouble(CrownMatch match, Game game, CrownMatchSimplex simplex) {
        // 情况1
        this.goalsBigSmallAndSingleDouble(match, game, simplex, "A");
        // 情况2
        this.goalsBigSmallAndSingleDouble(match, game, simplex, "B");
        // 情况3
        this.goalsBigSmallAndSingleDouble(match, game, simplex, "C");
        // 情况4
        this.goalsBigSmallAndSingleDouble(match, game, simplex, "D");
    }

    /**
     * 不同情况 "进球 大/小 & 进球 单/双" 方法抽取
     *
     * @param game
     * @param simplex
     * @param stage
     */
    private void goalsBigSmallAndSingleDouble(CrownMatch match, Game game, CrownMatchSimplex simplex, String stage) {
        try {
            // 拼接方法名getSw_OUEA()并执行
            String result = (String) Game.class.getMethod("getSw_OUE" + stage).invoke(game);
            // 判断玩法是否开启
            if ("N".equals(result)) {
                return;
            }
            this.clearAttr(simplex);

            String coeNum;
            int no2;
            // 固定系数
            switch (stage) {
                case "A":
                    coeNum = "1.5";
                    no2 = 1;
                    break;
                case "B":
                    coeNum = "2.5";
                    no2 = 2;
                    break;
                case "C":
                    coeNum = "3.5";
                    no2 = 3;
                    break;
                case "D":
                    coeNum = "4.5";
                    no2 = 4;
                    break;
                default:
                    throw new BizException("stage参数传错：" + stage);
            }

            simplex.setNo1(50);
            simplex.setNo2(no2);
            simplex.setCoeNum(coeNum);

            // 单 &进球大
            simplex.setNo3(1);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_OUE" + stage + "OO").invoke(game));
            simplex.setCoeWord("单&大");
            this.compose(simplex);

            // 单 &进球小
            simplex.setNo3(-1);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_OUE" + stage + "UO").invoke(game));
            simplex.setCoeWord("单&小");
            this.compose(simplex);


            // 双 &进球大
            simplex.setNo3(2);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_OUE" + stage + "OE").invoke(game));
            simplex.setCoeWord("双&大");
            this.compose(simplex);

            // 双 &进球小
            simplex.setNo3(-2);
            simplex.setOdds((BigDecimal) Game.class.getMethod("getIor_OUE" + stage + "UE").invoke(game));
            simplex.setCoeWord("双&小");
            this.compose(simplex);

        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
            log.error(e.getMessage());
            throw new BizException("爬取所有玩法反射异常,e:" + e.getMessage());
        }
    }


    /**
     * 赢得任一半场
     *
     * @param game
     * @param simplex
     */
    private void winAnyHalfCourt(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_WE())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(51);

        // 主队赢得任一半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_WEH());
        this.compose(simplex);

        // 客队赢得任一半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_WEC());
        this.compose(simplex);
    }


    /**
     * 赢得所有半场
     *
     * @param game
     * @param simplex
     */
    private void winAllHalfCourt(Game game, CrownMatchSimplex simplex) {
        if ("N".equals(game.getSw_WB())) {
            return;
        }
        this.clearAttr(simplex);

        simplex.setNo1(52);

        // 主队赢得任意半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(1);
        simplex.setOdds(game.getIor_WBH());
        this.compose(simplex);

        // 客队赢得任意半场
        simplex.setNo2(game.getIndex());
        simplex.setNo3(2);
        simplex.setOdds(game.getIor_WBC());
        this.compose(simplex);
    }
}